/**
 * MarkdownBlog Modern Design System
 * A contemporary design system with glassmorphism, subtle animations,
 * and modern UI patterns that distinguish us from Bootstrap-like sites.
 */

:root {
  /* ============================================
     MODERN COLOR PALETTE
     ============================================ */
  
  /* Brand Colors - Modern gradient-friendly palette */
  --color-primary: #6366f1;
  --color-primary-50: #eef2ff;
  --color-primary-100: #e0e7ff;
  --color-primary-200: #c7d2fe;
  --color-primary-500: #6366f1;
  --color-primary-600: #5b5bd6;
  --color-primary-700: #4c46d6;
  --color-primary-900: #312e81;
  
  /* Accent Colors */
  --color-accent: #06b6d4; /* Cyan */
  --color-accent-light: #67e8f9;
  --color-accent-dark: #0891b2;
  
  /* Status Colors - More vibrant and modern */
  --color-success: #10d982; /* Brighter green */
  --color-success-light: #6ee7b7;
  --color-success-dark: #047857;
  
  --color-warning: #fbbf24; /* Warmer yellow */
  --color-warning-light: #fde68a;
  --color-warning-dark: #d97706;
  
  --color-error: #f87171; /* Softer red */
  --color-error-light: #fca5a5;
  --color-error-dark: #dc2626;
  
  --color-info: --color-accent;
  
  /* Neutral Colors - Warmer and more sophisticated */
  --neutral-0: #ffffff;
  --neutral-50: #fafafa;
  --neutral-100: #f5f5f5;
  --neutral-200: #e5e5e5;
  --neutral-300: #d4d4d4;
  --neutral-400: #a3a3a3;
  --neutral-500: #737373;
  --neutral-600: #525252;
  --neutral-700: #404040;
  --neutral-800: #262626;
  --neutral-900: #171717;
  --neutral-950: #0a0a0a;

  /* ============================================
     THEME COLORS (Light Theme)
     ============================================ */
  
  /* Backgrounds with subtle gradients */
  --bg-primary: linear-gradient(135deg, #ffffff 0%, #fafafa 100%);
  --bg-secondary: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  --bg-tertiary: var(--neutral-100);
  --bg-quaternary: var(--neutral-200);
  
  /* Glass morphism backgrounds */
  --bg-glass: rgba(255, 255, 255, 0.8);
  --bg-glass-strong: rgba(255, 255, 255, 0.95);
  --bg-glass-subtle: rgba(255, 255, 255, 0.6);
  
  /* Elevated surfaces */
  --bg-elevated: linear-gradient(135deg, #ffffff 0%, #f9fafb 100%);
  --bg-card: var(--bg-glass-strong);
  --bg-modal: var(--bg-glass-strong);
  
  /* Text Colors */
  --text-primary: var(--neutral-900);
  --text-secondary: var(--neutral-600);
  --text-tertiary: var(--neutral-500);
  --text-quaternary: var(--neutral-400);
  --text-muted: var(--neutral-400);
  --text-disabled: var(--neutral-300);
  
  /* Border Colors */
  --border-primary: var(--neutral-200);
  --border-secondary: var(--neutral-300);
  --border-subtle: var(--neutral-100);
  --border-strong: var(--neutral-400);
  
  /* Interactive States */
  --hover-bg: rgba(99, 102, 241, 0.05);
  --active-bg: rgba(99, 102, 241, 0.1);
  --focus-ring: 0 0 0 3px rgba(99, 102, 241, 0.12);
  
  /* ============================================
     TYPOGRAPHY SYSTEM
     ============================================ */
  
  /* Font Families - Modern font stack */
  --font-primary: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-heading: 'Cal Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Monaco', 'Cascadia Code', monospace;
  
  /* Font Sizes - Fluid typography */
  --text-xs: clamp(0.75rem, 0.7rem + 0.2vw, 0.8rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.3vw, 0.95rem);
  --text-base: clamp(1rem, 0.95rem + 0.3vw, 1.1rem);
  --text-lg: clamp(1.125rem, 1rem + 0.5vw, 1.3rem);
  --text-xl: clamp(1.25rem, 1.1rem + 0.6vw, 1.5rem);
  --text-2xl: clamp(1.5rem, 1.3rem + 0.8vw, 1.9rem);
  --text-3xl: clamp(1.875rem, 1.6rem + 1.2vw, 2.5rem);
  --text-4xl: clamp(2.25rem, 1.9rem + 1.5vw, 3.2rem);
  --text-5xl: clamp(3rem, 2.5rem + 2vw, 4.5rem);
  
  /* Font Weights */
  --weight-light: 300;
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --weight-black: 900;
  
  /* Line Heights */
  --leading-tight: 1.25;
  --leading-snug: 1.375;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  --leading-loose: 2;
  
  /* ============================================
     SPACING SYSTEM (8px grid)
     ============================================ */
  
  --space-0: 0;
  --space-px: 1px;
  --space-0_5: 0.125rem; /* 2px */
  --space-1: 0.25rem;    /* 4px */
  --space-1_5: 0.375rem; /* 6px */
  --space-2: 0.5rem;     /* 8px */
  --space-2_5: 0.625rem; /* 10px */
  --space-3: 0.75rem;    /* 12px */
  --space-3_5: 0.875rem; /* 14px */
  --space-4: 1rem;       /* 16px */
  --space-5: 1.25rem;    /* 20px */
  --space-6: 1.5rem;     /* 24px */
  --space-7: 1.75rem;    /* 28px */
  --space-8: 2rem;       /* 32px */
  --space-9: 2.25rem;    /* 36px */
  --space-10: 2.5rem;    /* 40px */
  --space-11: 2.75rem;   /* 44px */
  --space-12: 3rem;      /* 48px */
  --space-14: 3.5rem;    /* 56px */
  --space-16: 4rem;      /* 64px */
  --space-20: 5rem;      /* 80px */
  --space-24: 6rem;      /* 96px */
  --space-28: 7rem;      /* 112px */
  --space-32: 8rem;      /* 128px */
  
  /* ============================================
     MODERN BORDER RADIUS
     ============================================ */
  
  --radius-none: 0;
  --radius-xs: 0.25rem;   /* 4px */
  --radius-sm: 0.375rem;  /* 6px */
  --radius-md: 0.5rem;    /* 8px */
  --radius-lg: 0.75rem;   /* 12px */
  --radius-xl: 1rem;      /* 16px */
  --radius-2xl: 1.5rem;   /* 24px */
  --radius-3xl: 2rem;     /* 32px */
  --radius-full: 9999px;
  
  /* Component-specific radius */
  --radius-button: var(--radius-lg);
  --radius-card: var(--radius-xl);
  --radius-modal: var(--radius-2xl);
  --radius-input: var(--radius-md);
  
  /* ============================================
     MODERN SHADOWS & ELEVATIONS
     ============================================ */
  
  /* Soft, modern shadows */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.06), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.05);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  
  /* Colored shadows for interactive elements */
  --shadow-primary: 0 10px 25px -12px rgba(99, 102, 241, 0.25);
  --shadow-success: 0 10px 25px -12px rgba(16, 217, 130, 0.25);
  --shadow-error: 0 10px 25px -12px rgba(248, 113, 113, 0.25);
  
  /* Glass morphism effects */
  --backdrop-blur: blur(16px);
  --backdrop-blur-sm: blur(8px);
  --backdrop-blur-lg: blur(24px);
  
  /* ============================================
     ANIMATION & TRANSITIONS
     ============================================ */
  
  /* Easing curves */
  --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0, 0, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  
  /* Duration */
  --duration-fast: 150ms;
  --duration-normal: 200ms;
  --duration-slow: 300ms;
  --duration-slower: 500ms;
  
  /* ============================================
     COMPONENT TOKENS
     ============================================ */
  
  /* Buttons */
  --btn-height-sm: 2.25rem; /* 36px */
  --btn-height-md: 2.75rem; /* 44px */
  --btn-height-lg: 3.25rem; /* 52px */
  
  --btn-padding-sm: var(--space-3) var(--space-4);
  --btn-padding-md: var(--space-3_5) var(--space-6);
  --btn-padding-lg: var(--space-4) var(--space-8);
  
  /* Forms */
  --input-height: var(--space-12); /* 48px */
  --input-padding: var(--space-4);
  --input-border-width: 1.5px;
  
  /* Cards */
  --card-padding: var(--space-6);
  --card-padding-sm: var(--space-4);
  --card-padding-lg: var(--space-8);
  
  /* Z-index scale */
  --z-dropdown: 1000;
  --z-modal: 2000;
  --z-toast: 3000;
  --z-tooltip: 4000;
}

/* ============================================
   DARK THEME
   ============================================ */

[data-theme="dark"] {
  /* Dark theme backgrounds */
  --bg-primary: linear-gradient(135deg, #0f0f23 0%, #1a1a3e 100%);
  --bg-secondary: linear-gradient(135deg, #1a1a3e 0%, #2a2a5e 100%);
  --bg-tertiary: var(--neutral-800);
  --bg-quaternary: var(--neutral-700);
  
  /* Dark glass morphism */
  --bg-glass: rgba(15, 15, 35, 0.8);
  --bg-glass-strong: rgba(15, 15, 35, 0.95);
  --bg-glass-subtle: rgba(15, 15, 35, 0.6);
  
  /* Dark elevated surfaces */
  --bg-elevated: linear-gradient(135deg, #1e1e40 0%, #2a2a4e 100%);
  --bg-card: var(--bg-glass-strong);
  --bg-modal: var(--bg-glass-strong);
  
  /* Dark text colors */
  --text-primary: var(--neutral-100);
  --text-secondary: var(--neutral-300);
  --text-tertiary: var(--neutral-400);
  --text-quaternary: var(--neutral-500);
  --text-muted: var(--neutral-500);
  --text-disabled: var(--neutral-600);
  
  /* Dark borders */
  --border-primary: rgba(255, 255, 255, 0.1);
  --border-secondary: rgba(255, 255, 255, 0.15);
  --border-subtle: rgba(255, 255, 255, 0.05);
  --border-strong: rgba(255, 255, 255, 0.2);
  
  /* Dark interactive states */
  --hover-bg: rgba(99, 102, 241, 0.1);
  --active-bg: rgba(99, 102, 241, 0.15);
  --focus-ring: 0 0 0 3px rgba(99, 102, 241, 0.2);
  
  /* Adjusted shadows for dark theme */
  --shadow-xs: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

/* ============================================
   BASE RESET & MODERN DEFAULTS
   ============================================ */

*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  height: 100%;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  height: 100%;
  font-family: var(--font-primary);
  font-size: var(--text-base);
  font-weight: var(--weight-normal);
  line-height: var(--leading-normal);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: hidden;
}

/* Modern focus styles */
*:focus {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Smooth theme transitions */
* {
  transition: 
    background-color var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out),
    color var(--duration-normal) var(--ease-out);
}

/* Typography improvements */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  letter-spacing: -0.025em;
}

h1 { font-size: var(--text-5xl); }
h2 { font-size: var(--text-4xl); }
h3 { font-size: var(--text-3xl); }
h4 { font-size: var(--text-2xl); }
h5 { font-size: var(--text-xl); }
h6 { font-size: var(--text-lg); }

p {
  line-height: var(--leading-relaxed);
}

/* Modern scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--neutral-300);
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-400);
  background-clip: content-box;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: var(--neutral-600);
  background-clip: content-box;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: var(--neutral-500);
  background-clip: content-box;
}

/* Selection styles */
::selection {
  background: rgba(99, 102, 241, 0.2);
  color: var(--text-primary);
}

/* Modern image defaults */
img, picture, video, canvas, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Form element improvements */
input, button, textarea, select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Remove button focus outline on click but keep for keyboard */
button:focus:not(:focus-visible) {
  outline: none;
}

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  :root {
    --border-primary: var(--neutral-400);
    --border-secondary: var(--neutral-500);
    --text-secondary: var(--neutral-700);
  }
  
  [data-theme="dark"] {
    --border-primary: var(--neutral-500);
    --border-secondary: var(--neutral-400);
    --text-secondary: var(--neutral-200);
  }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */

/* Glass morphism utility */
.glass {
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  border: 1px solid var(--border-subtle);
}

.glass-strong {
  background: var(--bg-glass-strong);
  backdrop-filter: var(--backdrop-blur-lg);
}

/* Modern gradients */
.gradient-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
}

.gradient-text {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-accent) 100%);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Animation utilities */
.animate-fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

.animate-slide-up {
  animation: slideUp var(--duration-normal) var(--ease-out);
}

.animate-scale {
  animation: scale var(--duration-normal) var(--ease-bounce);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { 
    opacity: 0; 
    transform: translateY(20px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

@keyframes scale {
  from { 
    opacity: 0; 
    transform: scale(0.95); 
  }
  to { 
    opacity: 1; 
    transform: scale(1); 
  }
}

/* Container utilities */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding-left: var(--space-4);
  padding-right: var(--space-4);
}

@media (min-width: 640px) {
  .container {
    padding-left: var(--space-6);
    padding-right: var(--space-6);
  }
}

@media (min-width: 1024px) {
  .container {
    padding-left: var(--space-8);
    padding-right: var(--space-8);
  }
}

/* Modern grid system */
.grid {
  display: grid;
  gap: var(--space-6);
}

.grid-cols-1 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (min-width: 640px) {
  .sm\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}